package com.hellpro.lolbox.mine.view;

import android.content.Context;
import android.content.SharedPreferences;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.hellpro.lolbox.R;
import com.hellpro.lolbox.base.LolBaseActivity;
import com.hellpro.lolbox.mine.presenter.LoginSettingPresenter;

import butterknife.BindView;
import butterknife.OnClick;

public class LoginSettingActivity extends LolBaseActivity implements ILoginSttingActivity {


    @BindView(R.id.mine_setting_btn_unLogin)
    Button mineSettingBtnUnLogin;
    @BindView(R.id.main_userName_iv_return)
    ImageView mainUserNameIvReturn;
    private LoginSettingPresenter presenter;
    private LinearLayout view;
    private Window window;
    private LinearLayout llUnLogin;

    @Override
    public int getLayoutId() {
        return R.layout.activity_login_setting;
    }

    @Override
    public void initView() {
        mineSettingBtnUnLogin.setVisibility(View.VISIBLE);
        presenter = new LoginSettingPresenter(this);
        view = (LinearLayout) LayoutInflater.from(this)
                .inflate(R.layout.setting_popup_window, null);
        window = getWindow();
        llUnLogin = (LinearLayout) view.findViewById(R.id.mine_unLogin);
        llUnLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                presenter.setBack();
                finish();
            }
        });
    }


    @Override
    public Button getBtnUnLogin() {
        return mineSettingBtnUnLogin;
    }

    @Override
    public SharedPreferences getSP() {
        return getSharedPreferences("isLogin", MODE_PRIVATE);
    }

    @Override
    public Context getLoginSettingContext() {
        return LoginSettingActivity.this;
    }

    @Override
    public LinearLayout getPopupWindow() {
        return view;
    }

    @Override
    public Window getLoginWindow() {
        return window;
    }

    @Override
    public LinearLayout getLlUnLogin() {
        return llUnLogin;
    }


    @OnClick({R.id.main_userName_iv_return, R.id.mine_setting_btn_unLogin})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.main_userName_iv_return:
                finish();
                break;
            case R.id.mine_setting_btn_unLogin:
                presenter.setUnLogin();
                break;
        }
    }
}
